<template>
  <div class="app-container flex-col minH">
    <div class="topline w100p bgwhite ptb20 radius10 pl10 pr20 justify-between">
      <div>
        <el-input v-model="uid" style="width: 280px" placeholder="搜尋陪玩ID..." @click="search()" :prefix-icon="Search" class="search" />



      </div>
      <div class="noshrink">
        <el-button class="btn2" @click="search()">查詢</el-button>
        <el-button class="btn1" @click="reset()">重置</el-button>
      </div>
    </div>
    <div class="mt15 radius10 hidden pb15 flex1 bgwhite  flex-col w100p">
      <div class="flex1 w100p ">
        <el-table :data="tableData" style="width: 100%" cell-class-name="tbcell" header-cell-class-name="hdcell">
          <el-table-column prop="uid" label="ID" width="100">
            <template #default="scope">
              <span @click="showUser(scope.row.uid)">{{ scope.row.uid }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="phone" label="用戶訊息" width="150" />
          <el-table-column prop="nickname" label="昵稱" width="150" />

          <el-table-column prop="sex" label="性別" width="80">
            <template #default="scope">
              <span>{{ scope.row.sex == 1 ? '男' : '女' }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="height" label="身高" width="80" />
          <el-table-column prop="weight" label="體重(kg)" width="80" />
          <el-table-column prop="city" label="城市" width="100" />
          <el-table-column prop="introduction" label="簡介" width="200" />
          <el-table-column prop="voice" label="語音" width="350">
            <template #default="scope">
              <audio controls :src="scope.row.voice"></audio>
            </template>
          </el-table-column>
          <el-table-column prop="cover_photo" label="封面圖片" width="100">
            <template #default="scope">
              <el-avatar shape="square" :size="50" :fit="'cover'" :src="scope.row.cover_photo" />
            </template>
          </el-table-column>
          <el-table-column prop="my_album" label="個人相冊" width="100">
            <template #default="scope">
              <el-image style="width: 50px; height: 50px" :src="scope.row.my_album[0]" :zoom-rate="1.2" :max-scale="7" :min-scale="0.2" :preview-src-list="scope.row.my_album" :initial-index="0" fit="cover" />
            </template>
          </el-table-column>
          <el-table-column prop="online_text" label="在綫狀態" width="100" />
          <el-table-column prop="address" label="審核人" width="100" />

          <el-table-column prop="state_text" label="審核狀態" width="100" />
          <el-table-column prop="reason" label="拒絕原因" width="180" />
          <el-table-column prop="created_at" label="創建時間" width="200" />
          <el-table-column prop="updated_at" label="更新時間" width="200" />
          <el-table-column prop="" label="操作" width="100" fixed="right">
            <template #default="scope">
              <div class=" pointer" @click="edit(scope.row)">編輯</div>
            </template>
          </el-table-column>

        </el-table>
      </div>
      <div class="  plr20 mlauto mt15">
        <el-pagination v-model:current-page="currentPage" prev-text="上一頁" next-text="下一頁" :default-page-size="15" :small="small" :disabled="disabled" :background="true" layout="prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>

    </div>
  </div>
</template>

<script setup>
import { Search } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue'
import { useRouter, } from 'vue-router';
import { stateList } from '@/api/player.js'
import { inject } from 'vue';
const showUser = inject('showUser');
onMounted(() => {
  getStateList()
})
// 审核列表
const getStateList = () => {
  stateList({
    page: currentPage.value,
    uid: uid.value
  }).then((res) => {
    console.log('分类列表', res)
    tableData.value = res.data.data
    total.value = res.data.total
  })
}
const uid = ref('')
const dialogTableVisible = ref(false)
const dialogType = ref(1)
const dialogShow = (type) => {
  console.log('dialog----show----')
  dialogType.value = type
  dialogTableVisible.value = true
}
const reset = () => {
  uid.value = ''
  getStateList()
}
const search = () => {
  console.log('搜尋')
  getStateList()
}
const tableData = ref([])
const tableRowClassName = () => {
  return 'tbrow'
}
const currentPage = ref(1)
const total = ref(0)
const handleSizeChange = (val) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = (val) => {
  console.log(`current page: ${val}`)
}
const router = useRouter()

const edit = (row) => {
  router.push({ path: 'editCheck', query: { id: row.id, state: row.state } })
}
</script>

<style lang="scss" scoped>
.search {
  overflow: hidden;
  border-radius: 10px !important;
  // padding: 5px 0px;
}

:deep(.el-input__wrapper) {
  box-shadow: none;
}

:deep(.el-table .el-table__cell) {
  z-index: auto !important;
}
</style>
<style></style>
 